﻿#region Usings

using FluentValidation;
using Yandex.Market.Api.Model;

#endregion

namespace Yandex.Market.Api.Validation
{
    internal class OfferEventTicketValidator : OfferBaseValidator<OfferEventTicket>
    {
        public OfferEventTicketValidator()
        {
            RuleFor(offer => offer.Name).NotEmpty();
            RuleFor(offer => offer.Place).NotEmpty();
            RuleFor(offer => offer.Date).NotEmpty();
            RuleFor(offer => offer.Hall).SetValidator(new HallValidator()).When(offer => offer.Hall != null);
// ReSharper disable PossibleInvalidOperationException
            RuleFor(offer => offer.IsPremiere.Value).Must(value => value == 0 || value == 1).When(offer =>
                                                                                                  offer.IsPremiere.HasValue);                                                                                                                                                                                                        
            RuleFor(offer => offer.IsKids.Value).Must(value => value == 0 || value == 1).When(offer =>
                                                                                              offer.IsKids.HasValue);
                                                                                              
// ReSharper restore PossibleInvalidOperationException
        }
    }
}